﻿@{
    var requierd = string.Empty;
    if(Model.ExtendRuleValues!=null && Model.ExtendRuleValues.Count > 0)
    {
        var listrulevalues= Model.ExtendRuleValues as List<InputStyleRule>;
        var requiredModel= listrulevalues.Where(a => a.Type== ValidateType.Required.ToString()).FirstOrDefault();
        if (requiredModel!=null)
        {
            requierd = requiredModel.Message;
        }
    }
    List<InputStyleItemVuale> itemvuale=null;
    if(Model.ExtendItemValues!=null && Model.ExtendItemValues.Count > 0)
    {
        itemvuale = Model.ExtendItemValues as List<InputStyleItemVuale>;
    }
    StringBuilder sb = null;
    foreach (var item in itemvuale)
    {
        if (sb == null)
        {
            sb= new StringBuilder();
            sb.Append("{ name:\""+item.Label+"\", value:\""+item.Value+"\" }");
        }
        else
        {
            sb.Append(",{ name:\""+item.Label+"\", value:\""+item.Value+"\" }");
        }
    }
    <div class="layui-form-item">
                            <label class="layui-form-label @(!string.IsNullOrEmpty(requierd)?"layui-form-required":"")">@Model.DisplayName</label>
                            <div class="layui-input-block">
                            <div id="xm_@Model.AttributeName" xm-select-skin="normal"></div>
                            </div>
    </div>
    <script>
           var xmdata_@Model.AttributeName=[@Html.Raw( sb.ToString())];
          
            var xm_@Model.AttributeName = xmSelect.render({
                el: '#xm_@Model.AttributeName',
                language: 'zn',
                size:'small',
                theme: {
		            color: localStorage.getItem("theme-color-color")??'#1cbbb4',
	            },
                name:'@Model.AttributeName',
                @(!string.IsNullOrEmpty(requierd)?"layVerify:\"required\",":"")
                layReqText:'@requierd',
                data: xmdata_@Model.AttributeName,
                initValue:[@Model.DefaultValue]
            });

    </script>
}
  